#ifndef THREAD_H
#define THREAD_H

#include <QObject>
#include <QThread>
#include <QMessageBox>
#include <button.h>
#include <processes.h>

#define EST_RUN 1
#define EST_STOP 0

class Thread : public QThread {
    Q_OBJECT

signals:

    /** ----------------------------------------------------------------------
    * @brief Creating events to after running.
    */
    void repaint(int);


public:

    int i;
    int state;

    /** ----------------------------------------------------------------------
    * @brief Thread constructor receive device combo and network references
    * to allow work with them.
    */
    Thread(){
        i=0;
        state=EST_RUN;
    }

    /** ----------------------------------------------------------------------
    * @brief run method has actions to exec in thread.
    */
    void run() {
        while(1){
            if(state==EST_RUN){
                sleep(1);
                i++;
                emit(repaint(i));
            }else break;
        }
    }

    //----------------------------------------------------------------------------
    void stop(){
        state=EST_STOP;
    }

    //----------------------------------------------------------------------------
    void resume(){
        state=EST_RUN;
    }
};

#endif // THREAD_H
